package com.tsunami.authority.enums.common;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tsunami.base.BaseEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @author Admin
 */

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "通用状态标志-枚举")
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ComStatus implements BaseEnum {
    /**
     * N="正常"
     */
    N("正常"),
    /**
     * F="停用"
     */
    F("停用"),
    ;

    @Schema(description = "描述")
    private String desc;


    public static ComStatus match(String val, ComStatus def) {
        for (ComStatus enm : ComStatus.values()) {
            if (enm.name().equalsIgnoreCase(val)) {
                return enm;
            }
        }
        return def;
    }

    public static ComStatus get(String val) {
        return match(val, null);
    }

    public boolean eq(String val) {
        return this.name().equalsIgnoreCase(val);
    }

    public boolean eq(ComStatus val) {
        if (val == null) {
            return false;
        }
        return eq(val.name());
    }


    @Override
    public String getCode() {
        return BaseEnum.super.getCode();
    }

    @Override
    public String getDesc() {
        return this.desc;
    }
}
